package lab02;

/**
 * Created by JAVA on 2017/9/29.
 */
import java.util.Scanner;
public class Test03 {
    public static void main(String[] args) {
          /*  int i=0;
            int j=0;
            for (i=1;i<=9 ;i++ ){
                for (j=i;j<=i ;j++ )
                    System.out.print(i+"*"+j+"="+i*j+"\t");
                System.out.println();
            }
        }*/
        // public static void main(String[] args) {
                /*    Scanner in=new Scanner(System.in);
                    System.out.println("请猜一下电脑随机数是多少（1-100）");//折半查找法
                    int sum=0;//
                    int a=in.nextInt ();
                    //sum++;
                    int b=(int)(Math.random()*100);
                    while(a!=b){
                        sum++;
                        if (a<b){
                            System.out.println("小了");
                            //sum++;
                        }
                        else {
                            System.out.println("大了");
                            //sum++;
                        }
                        System.out.println("请再猜一个数：");
                        a=in.nextInt();
                    }
                    System.out.println("恭喜你猜对啦！开心^-^是"+b);
                    System.out.println("猜的次数："+sum);
                }
            }*///附加上猜了几次。
 /*Scanner in = new Scanner(System.in);
        System.out.println("请输入数字1到100：");
        int number = (int) (Math.random() * 100) + 1;
        do {
            System.out.println("请猜电脑的随机数：");
            int a = in.nextInt();
            if (number < a) {
                System.out.println("猜小了");
            } else if (number > a) {
                System.out.println("猜大了");
            }
            while (number != a) ;
            System.out.println("恭喜你，猜对了");
        }*/
        String[] s = new String[]{"A", "B", "C", "D", "E", "F",
                "G", "H", "I", "J", "K", "L", "M",
                "N", "O", "P", "Q", "R", "S", "T"};
        //建立一个一维数组

        int i;
        int j;
        int k;
        //i，j，k为for循环的条件

        int num1 = 0;
        int num2 = 10;
        //num1、2是为了输出一维数组

        for (i = 1; i < 5; i++) {    //控制行数
            for (j = 0; j < 4 - i; j++) {
                System.out.print(" ");
            }
            //控制字母前空格的数量

            for (k = 0; k < i; k++) {
                System.out.print(s[num1]);
                System.out.print(" ");
                num1++;
            }
            //控制字母的输出

            System.out.println();    //控制换行
        }

        for (i = 1; i < 5; i++) {
            for (j = 1; j < i; j++) {
                System.out.print(" ");
            }
            for (k = 5; k > i; k--) {
                System.out.print(s[num2]);
                System.out.print(" ");
                num2++;
            }
            System.out.println();
        }
    }
}

